using BuildingBlocks.Core.Entities;

namespace Identity.Domain.ValueObjects
{
    public class PermissionScope : ValueObject
    {
        public string Value { get; private set; }

        private PermissionScope(string value) => Value = value;

        public static PermissionScope Local => new("Local");
        public static PermissionScope Centralized => new("Centralized");

        public bool IsLocal => Value == "Local";
        public bool IsCentralized => Value == "Centralized";

        protected override IEnumerable<object> GetEqualityComponents()
        {
            yield return Value;
        }

        public static PermissionScope From(string value)
        {
            return value switch
            {
                "Local" => Local,
                "Centralized" => Centralized,
                _ => throw new ArgumentException($"Invalid scope: {value}")
            };
        }
    }

}